package poo.esempi;

import java.util.Scanner;
import java.util.StringTokenizer;

public class ValutaEspressione {

	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		System.out.println(">");
		String linea = sc.nextLine();
		StringTokenizer st = new StringTokenizer(linea, "+-*/", true);
		int ris = Integer.parseInt(st.nextToken());

		while (st.hasMoreTokens()) {
			String op = st.nextToken();
			int opnd = Integer.parseInt(st.nextToken());
			switch (op) {
			case "+":
				ris += opnd;
				break;
			case "-":
				ris -= opnd;
				break;
			case "*":
				ris *= opnd;
				break;
			case "/":
				ris /= opnd;
				break;
			default:
				throw new RuntimeException("Espressione Malformata");
			}
		}

		System.out.println(linea + "=" + ris);
		sc.close();
	}

}
